<template>
  <div id="taskdetail" v-loading="loading">
    <v-tableTitle :btnConfig="btnConfig" :tableSelectData="tableSelectData" :title="$t('config.task')" @del="del"
      @cancel="cancel"></v-tableTitle>
      <GTable ref="table" :hasCheck="true" :hasEdit="true" :showSummary="true" dateKey="adddate" api="queryTaskdetailList" :otherHeight="0" :columnConfig="columnConfig" @selection-change="selectData" @setdialog="setdialog" > </GTable>
  </div>
</template>

<script type="text/ecmascript-6">
import tableTitle from "commons/TableTitle";
import baseMixin from "@/mixins/BaseMixin";
import config from "./Config";
import bus from "../../../../bus/bus"

export default {
  name: "taskdetail",
  mixins: [baseMixin, config],
  data() {
    return {
      loading: false,
      tableSelectData: [],
      columnConfig:{ menu_id: 64, menu_code:"taskdetail", menu_list_code:"taskList"},
    };
  },
  computed: {
    btnConfig() {
      return [
        { label: this.$t('common.delete'), certigier:!this.btnPermNameList.includes('WM06010101'), disabled: true, invalid: "del" },
        { label: this.$t('common.cancel'), certigier:!this.btnPermNameList.includes('WM06010102'), disabled: true, invalid: "cancel" },
      ]
    }
  },
  created() {
  },
  methods: {
    //选中的内容
    selectData(data) {
      this.tableSelectData = data;
    },
    //删除
    async del(data) {
      try {
        let res = await this.$api.post(`/deleteTaskdetail`, data);
        
          this.$message.success(res.returnMgr);
          this.$refs.table.getTableData();
        
      } catch (e) {
        this.$message.error(e);
      }
    },
    async cancel(data) {
      try {
        let res = await this.$api.post(`/cancelTaskdetail`, data);
        
          this.$message.success(res.returnMgr);
          this.$refs.table.getTableData();
        
      } catch (e) {
        this.$message.error(e);
      }
    },
    //设置弹框
    setdialog(data) {
      this.$store.commit("setRouteData", data);
      this.$router.push({ name: 'taskdetailDeawer' });
    },
  },
  mounted() {
    this.$store.commit("setSkip", {});
    this.$store.commit("setNewFlag", false);
    this.$store.commit("setRouteData", {});
  },
  components: {
    "v-tableTitle": tableTitle,
  }
};
</script>

<style scoped>
#taskdetail {
  width: 100%;
  height: 99%;
  padding-top: 6px;
}
</style>
